<template>
  <div class="app-container">
    <div
      v-show="
        !inventoryDataEntryInfo.visible &&
        !inventoryProfitLossInfo.visible &&
        !storeDetailInfo.visible &&
        !exportDetailInfo.visible
      "
    >
      <!-- 条件栏 -->
      <div class="filter-wrapper">
        <NewPageFilter
          v-model:query="filterInfo.query.queryMap"
          :query-more-json="true"
          :filter-list="filterInfo.searchList"
          :filter-btn="filterInfo.searchBtn"
          :clear-type="clearType"
          :slip-select-request="slipSelectRequest"
        ></NewPageFilter>
      </div>
      <div class="filter-wrapper">
        <NewPageFilter :filter-btn="filterInfo.btnList"> </NewPageFilter>
        <div class="display-flex">
          <el-button @click="preferenceInfo.visible = true">偏好设置</el-button>
        </div>
      </div>
      <!-- 表格 -->
      <TableContainer
        :refresh="tableInfo.refresh"
        :init-curpage="tableInfo.initCurpage"
        v-model:data="tableInfo.data"
        :api="tableInfo.api"
        v-model:query="filterInfo.query"
        :field-list="tableInfo.fieldList"
        :handle="tableInfo.handle"
        :check-box="false"
        :tab-index="true"
        :row-class-name="tableRowClassName"
        @sortChange="sortChange"
        @handleEvent="handleEvent"
      >
        <template v-slot:col-orderNo="scope">
          <span
            v-if="scope.row.status === 3"
            class="slip-edit"
            @click="showProfitLoss(scope.row)"
            >{{ scope.row.orderNo || '-' }}</span
          >
          <span v-else>{{ scope.row.orderNo || '-' }}</span>
        </template>
      </TableContainer>
    </div>
    <!-- 新增修改弹窗 -->
    <PageDialog
      v-if="dialogInfo.visible"
      :title="dialogInfo.title[dialogInfo.type]"
      v-model:visible="dialogInfo.visible"
      :width="dialogInfo.width"
      :bt-loading="dialogInfo.btLoading"
      :bt-list="dialogInfo.btList"
    >
      <!-- form -->
      <PageForm
        class="paddingBox order-model-formBox flex_wrap_start_start"
        v-model:ref-obj="formInfo.ref"
        :data="formInfo.data"
        :list-type-info="listTypeInfo"
        :field-list="formInfo.fieldList"
        :rules="formInfo.rules"
        :label-width="formInfo.labelWidth"
        @handleEvent="handleEventForm"
      >
        <template v-slot:form-inventoryOrderProducts>
          <el-input
            v-model="formInfo.commonName"
            class="not-mongolia"
            type="input"
            :disabled="true"
            placeholder="请选择盘点产品"
          >
            <template #append>
              <el-icon @click="selectProduct"><MoreFilled /></el-icon>
            </template>
          </el-input>
        </template>
      </PageForm>
    </PageDialog>

    <!-- 数据录入 -->
    <dataEntry
      v-if="inventoryDataEntryInfo.visible"
      v-model:visible="inventoryDataEntryInfo.visible"
      :table-row="inventoryDataEntryInfo.tableRow"
      :title="inventoryDataEntryInfo.title"
      @returnModify="handleModify"
    />

    <!-- 查看损益 -->
    <inventory-profit-loss
      v-if="inventoryProfitLossInfo.visible"
      v-model:visible="inventoryProfitLossInfo.visible"
      :table-row="inventoryProfitLossInfo.tableRow"
      @returnBack="getList"
    />
    <SetPreference
      v-if="preferenceInfo.visible"
      v-model:visible="preferenceInfo.visible"
      :search-list="filterInfo.searchList"
      :field-list="tableInfo.fieldList"
      :customize-user-v-o="filterInfo.query.customizeUserVO"
      :group-level-show="false"
      @callback="setPreferenceCallback"
    />
    <AdvancedSearch
      v-if="advancedSearchInfo.visible"
      v-model:visible="advancedSearchInfo.visible"
      v-model:form-data="advancedSearchInfo.data"
      :field-list="tableInfo.fieldList"
      @callback="advancedSearchCallback"
    />
    <NewSelectProduct
      v-if="productInfo.visible"
      v-model:show-dialog="productInfo.visible"
      :save-empty="true"
      :showSetPreference="true"
      row-key="productId"
      :checked-row-list="productInfo.checkedRowList"
      v-model:query="productInfo.query"
      tableKey="stockInventoryProductPageWithDefaultSupplier-com.slip.spd.entity.vo.core.CoreProductVONew"
      @callback="callbackProduct"
    />
    <InventoryAndExportDetail
      v-if="exportDetailInfo.visible"
      v-model:visible="exportDetailInfo.visible"
      :table-row="exportDetailInfo.data"
      @returnBack="getList"
    />
    <InventoryAndStorageDetail
      v-if="storeDetailInfo.visible"
      v-model:visible="storeDetailInfo.visible"
      :table-row="storeDetailInfo.data"
      @returnBack="getList"
    />
  </div>
</template>

<script setup name="inventory">
import {
  createInventoryOrder,
  getInventoriesCustomizeListPage,
  getInventoryOrderById,
  getInventoryOrderOfflinePrint,
  getInventoryOrderOfflineSimplePrint,
  inventoriesNotOnlineExcel,
  inventoriesUnLockStock,
  inventoryOrderLockStock,
  updateInventoryOrder,
} from '@/api/stock'
import { getDepotAll } from '@/api/core'
import InventoryAndExportDetail from '@/views/stock/inventoryAndExport/detail'
import InventoryAndStorageDetail from '@/views/stock/inventoryAndStorage/detail'
import InventoryProfitLoss from './profitLoss'
import { getCustomizeSetting, updateUserCustomize } from '@/api/customize'
import { fatchTemplateByCode } from '@/api/base'
import {
  setDisableTime,
  _getCurrentFiscalPeriod,
} from '@/common/js/dateOperation'
import { toSourceDetail } from '@/common/js/base.js'
const { proxy } = getCurrentInstance()
const dataEntry = defineAsyncComponent(() => import('./dataEntry'))
const systemConfig = ref(proxy.$store.state.permission.systemConfig)
const storeDetailInfo = ref({
  visible: false,
  data: {},
})
const exportDetailInfo = ref({
  visible: false,
  data: {},
})
const listTypeInfo = ref({
  depotList: [],
})
// 过滤相关配置
const filterInfo = ref({
  sortArr: [],
  copyQueryMap: {},
  query: {
    sortString: '',
    queryMap: {
      depotAuth: {
        asTbName: 'inventory_order',
        columnName: 'depot_id',
        queryType: 'IN',
        queryCategory: 'AND',
        value: 'depotAuth',
      },
      isGoodsLocation: {
        queryType: 'IN',
        value: 0,
      },
    },
    customizeUserVO: {},
  },
  searchList: [],
  searchBtn: [
    { type: 'button', label: '搜索', event: search },
    { type: 'button', label: '高级查询', event: advancedSearchShow },
    { type: 'button', label: '重置', event: clearSearch },
  ],
  btnList: [
    {
      type: 'button',
      label: '新增',
      event: create,
      show: proxy.$permission('inventories:add'),
    },
  ],
})
// 表格相关
const tableInfo = ref({
  refresh: 1,
  initCurpage: 1,
  api: undefined,
  data: [],
  selections: [],
  fieldList: [],
  handle: {
    fixed: 'right',
    label: '操作',
    width: '160',
    btList: [
      {
        label: '修改',
        event: update,
        show: proxy.$permission('inventories:update'),
        ifRender: function (row) {
          return row.status === 1
        },
      },
      {
        label: '锁库',
        event: lockStock,
        show: proxy.$permission('inventories:lockStock'),
        ifRender: function (row) {
          return row.status === 1
        },
      },
      {
        label: '数据录入',
        event: _dataEntry,
        show: proxy.$permission('inventories:dataEntry'),
        ifRender: dataEnterIfRender,
      },
      {
        label: '打印盘点表',
        event: printOffline,
        show: proxy.$permission('inventories:printOffline'),
        ifRender: function (row) {
          return [2, 4].includes(row.status)
        },
      },
      {
        label: '打印盘点表(只要总数)',
        event: printOfflineSimple,
        show: proxy.$permission('inventories:printOfflineSimple'),
        ifRender: function (row) {
          return [2, 4].includes(row.status)
        },
      },
      {
        label: '导出盘点表',
        event: outputInventory,
        show: proxy.$permission('inventories:offlineExport'),
        ifRender: function (row) {
          return [2, 4].includes(row.status)
        },
      },
      {
        label: '关闭',
        event: unlock,
        show: proxy.$permission('inventories:unLockStock'),
        ifRender: function (row) {
          return [1, 2, 4].includes(row.status)
        },
      },
      {
        label: '查看损益',
        event: showProfitLoss,
        show: proxy.$permission('inventories:profitLoss'),
        ifRender: function (row) {
          return row.status === 3
        },
      },
      {
        label: '盘点入库单',
        event: showStoreOrder,
        show: true,
        // show: proxy.$permission('inventories:storeOrder'),
        ifRender: function (row) {
          return (
            row.status === 3 &&
            row.inventoryStoreOrderId &&
            row.inventoryStoreOrderId !== -2
          )
        },
      },
      {
        label: '盘点出库单',
        event: showExportOrder,
        show: true,
        // show: proxy.$permission('inventories:exportOrder'),
        ifRender: function (row) {
          return (
            row.status === 3 &&
            row.inventoryExportOrderId &&
            row.inventoryExportOrderId !== -2
          )
        },
      },
    ],
  },
})
// 表单相关
const formInfo = ref({
  ref: null,
  commonName: '',
  data: {
    depotId: '',
    useSub: '',
    inventoryOrderProducts: [],
    isConsignBusiness: 0,
    remark: '',
  },
  fieldList: [
    {
      label: '盘点仓库',
      value: 'depotId',
      type: 'select',
      list: 'depotList',
      event: 'depot',
      filterable: true,
      required: true,
    },
    {
      label: '是否子盘点',
      value: 'useSub',
      type: 'select-model',
      code: 'use_sub',
    },
    {
      label: '寄售业务',
      value: 'isConsignBusiness',
      type: 'select-model',
      code: 'default_no_or_yes',
      event: 'isConsignBusiness',
      show: proxy.$store.state.permission.systemConfig.is_consign_business == 1,
    },
    {
      label: '零星盘点',
      value: 'inventoryOrderProducts',
      type: 'slot',
    },
    {
      label: '盘点数量默认值',
      value: 'inventoryQtyType',
      type: 'select-model',
      code: 'inventory_qty_type',
      disabled: false,
    },
    {
      label: '业务日期',
      value: 'businessDate',
      type: 'date',
      required: true,
      clearable: false,
    },
    {
      label: '备注',
      value: 'remark',
      type: 'textarea',
    },
  ],
  labelWidth: '120px',
})
// 弹窗相关
const dialogInfo = ref({
  title: {
    create: '新增',
    update: '修改',
  },
  visible: false,
  type: '',
  width: '660px',
  btLoading: false,
  btList: [
    { label: '关闭', type: '', icon: '', event: close, show: true },
    {
      label: '保存',
      type: 'primary',
      icon: '',
      event: save,
      saveLoading: false,
      show: true,
    },
  ],
})
//数据录入相关
const inventoryDataEntryInfo = ref({
  visible: false,
  title: '',
  tableRow: {},
})
//查看损益相关
const inventoryProfitLossInfo = ref({
  visible: false,
  tableRow: {},
})
const depotLists = ref([])
const preferenceInfo = ref({
  visible: false,
})
const advancedSearchInfo = ref({
  visible: false,
  data: {},
})
const productInfo = ref({
  visible: false,
  tableKey: 'searchByProdectId-com.slip.spd.entity.vo.core.CoreProductVONew',
  checkedRowList: [],
  query: {
    isConsignment: {
      queryType: 'IN',
      queryCategory: 'AND',
      value: '',
    },
  },
})
const clearType = ref(true)
const slipSelectRequest = ref(true)
watch(
  () => inventoryDataEntryInfo.value.visible,
  (value) => {
    if (!value) {
      getList()
    }
  }
)
watch(
  () => formInfo.value.data.useSub,
  (value) => {
    if (value == 1) {
      formInfo.value.fieldList.forEach((item) => {
        if (item.value === 'inventoryQtyType') {
          formInfo.value.data['inventoryQtyType'] = 0
          item.disabled = true
        }
      })
    } else {
      formInfo.value.fieldList.forEach((item) => {
        if (item.value === 'inventoryQtyType') {
          item.disabled = false
        }
      })
    }
  },
  {
    immediate: true,
  }
)

const toPage = computed(() => {
  return proxy.$store.state.settings.toPage
})
let stopWatch = function () {}
onActivated(() => {
  stopWatch = watch(
    () => toPage.value,
    (val) => {
      if (val) {
        let menus = proxy.$store.state.permission.defaultMenus
        menus.forEach((item) => {
          if (item.children) {
            item.children.forEach((el) => {
              if (el.code === 'inventory' && el.url === val.url) {
                inventoryProfitLossInfo.value.visible = false
                if (val.urlType === 1) {
                  getList()
                } else if (val.urlType === 2) {
                  proxy.$nextTick(() => {
                    inventoryProfitLossInfo.value.visible = true
                    inventoryProfitLossInfo.value.tableRow = {
                      id: val.businessId,
                    }
                    sessionStorage.setItem('storeRowId', val.businessId)
                  })
                }
                proxy.$store.dispatch('settings/toPage', '')
              }
            })
          }
        })
      }
    },
    {
      deep: true,
      immediate: true,
    }
  )
})
onDeactivated(() => {
  stopWatch()
})
let disStartDate = ref('')
let disEndDate = ref('')
async function setBusinessDate() {
  formInfo.value.data.businessDate = await _getCurrentFiscalPeriod(
    formInfo.value.fieldList,
    proxy,
    disStartDate,
    disEndDate
  )
}
function tableRowClassName({ row }) {
  let rowId = sessionStorage.getItem('storeRowId')
  if (rowId && row.id === Number(rowId)) {
    return 'check-row'
  }
  return ''
}
function handleEventForm(event, val) {
  if (event === 'depot') {
    let item = depotLists.value.find((item) => item.id === val)
    if (item) {
      formInfo.value.data.deptId = item.deptId
      formInfo.value.data.useSub = item.defaultUseSub
    }
  } else if (event === 'isConsignBusiness') {
    // productInfo.value.query.isConsignment.value = val
  }
}
function dataEnterIfRender(row) {
  return [2, 4].includes(row.status)
}
function selectProduct() {
  productInfo.value.visible = true
}
function callbackProduct(row) {
  if (row.length) {
    formInfo.value.data.inventoryOrderProducts = row.map((item) => {
      return { productId: item.productId }
    })
    productInfo.value.checkedRowList = row
    formInfo.value.commonName = row.map((item) => item.commonName).toString()
  } else {
    formInfo.value.data.inventoryOrderProducts = []
    productInfo.value.checkedRowList = []
    formInfo.value.commonName = ''
  }
}
function setPreferenceCallback(obj) {
  updateUserCustomize(obj.customizeUserVO).then((res) => {
    if (res && res.success) {
      getCustomize(!slipSelectRequest.value)
    }
  })
}
function advancedSearchShow() {
  advancedSearchInfo.value.visible = true
}
async function advancedSearchCallback(obj) {
  let arr = [
    {
      asTbName: 'inventory_order',
      columnName: 'depot_id',
      queryType: 'IN',
      queryCategory: 'AND',
      value: 'depotAuth',
    },
  ]
  filterInfo.value.query.queryMap = {}
  filterInfo.value.query.queryDtoList = [...obj.queryDtoList, ...arr]
  advancedSearchInfo.value.data = obj.data
  await getList()
  clearType.value = !clearType.value
  filterInfo.value.query.queryMap = proxy.$fn.deepClone(
    filterInfo.value.copyQueryMap
  )
}
// 获取列表
async function getList() {
  tableInfo.value.refresh = Math.random()
}
// 初始化验证
function initRules() {
  formInfo.value.rules = proxy.$initRules(formInfo.value.fieldList)
}
// 搜索
function search() {
  // 重置分页
  advancedSearchInfo.value.data = {}
  filterInfo.value.query.queryDtoList = []
  tableInfo.value.initCurpage = Math.random()
  tableInfo.value.refresh = Math.random()
}
// 触发事件
function handleEvent(event, data) {
  switch (event) {
    case 'tableCheck':
      tableInfo.value.selections = [...data]
      break
  }
}
//初始化仓库下拉框
function initDepotList() {
  const params = {
    depotAuth: 'id',
    useTypeId: '1',
    status: 1,
    isCargoSpaceManage: 0,
  }
  getDepotAll(params).then((resp) => {
    if (resp && resp.success) {
      depotLists.value = resp.data
      listTypeInfo.value.depotList = resp.data.map((item) => {
        return {
          key: item.name,
          value: item.id,
        }
      })
      dialogInfo.value.visible = true
      setDisableTime(formInfo.value.fieldList, disStartDate, disEndDate)
      setBusinessDate()
    }
  })
}
//新增
function create() {
  formInfo.value.data = {
    depotId: '',
    useSub: '',
    inventoryOrderProducts: [],
    remark: '',
  }
  productInfo.value.checkedRowList = []
  formInfo.value.commonName = ''
  initDepotList()
}
//更新
function update(row) {
  getInventoryOrderById(row.id).then((res) => {
    if (res && res.success) {
      let data = res.data
      if (data.inventoryOrderProducts && data.inventoryOrderProducts.length) {
        productInfo.value.checkedRowList = data.inventoryOrderProducts
        formInfo.value.commonName = data.inventoryOrderProducts
          .map((item) => item.commonName)
          .toString()
        data.inventoryOrderProducts = data.inventoryOrderProducts.map(
          (item) => {
            return { productId: item.productId }
          }
        )
      }
      formInfo.value.data = data
      formInfo.value.data.useSub = data.useSub
      initDepotList()
    }
  })
}
//关闭弹窗
function close() {
  dialogInfo.value.visible = false
  formInfo.value.commonName = ''
  formInfo.value.data.depotId = ''
  formInfo.value.data.useSub = ''
  formInfo.value.data.remark = ''
  formInfo.value.data.isConsignBusiness = 0
  formInfo.value.data.inventoryOrderProducts = []
  productInfo.value.checkedRowList = []
  // productInfo.value.query.isConsignment.value = 0
}
//保存
function save() {
  formInfo.value.ref.validate((valid) => {
    if (valid) {
      let item = depotLists.value.filter(
        (item) => item.id === formInfo.value.data.depotId
      )
      if (item.length && item[0].lock) {
        proxy.$message({
          duration: 3500,
          type: 'warning',
          showClose: true,
          message: item[0].name + '已经被锁定，请等待解锁。',
        })
        return
      }
      if (item.length && item[0].frozenQty && item[0].frozenQty > 0) {
        proxy.$message({
          duration: 3500,
          type: 'warning',
          showClose: true,
          message: item[0].name + '库存在尚未出库的产品，请出库后再锁库。',
        })
        return
      }
      const data = formInfo.value.data
      const api = data.id ? updateInventoryOrder : createInventoryOrder
      api(data).then((resp) => {
        if (resp && resp.success) {
          close()
          getList()
        }
      })
    }
  })
}
function clearSearch() {
  clearType.value = !clearType.value
  advancedSearchInfo.value.data = {}
  filterInfo.value.query.queryMap = proxy.$fn.deepClone(
    filterInfo.value.copyQueryMap
  )
  search()
}
//锁库
function lockStock(row = undefined) {
  const ids = [row.id]
  inventoryOrderLockStock(ids).then((resp) => {
    if (resp && resp.success) {
      getList()
    }
  })
}
//数据录入
function _dataEntry(row) {
  sessionStorage.setItem('storeRowId', row.id)
  inventoryDataEntryInfo.value.tableRow = { ...row }
  inventoryDataEntryInfo.value.title = '数据录入'
  inventoryDataEntryInfo.value.visible = true
}
//查看损益
function showProfitLoss(row) {
  sessionStorage.setItem('storeRowId', row.id)
  inventoryProfitLossInfo.value.tableRow = { ...row, selectMode: '' }
  inventoryProfitLossInfo.value.visible = true
}
// 打印盘点表
function printOffline(row) {
  fatchTemplateByCode({
    resourceCode: 'inventories:printOffline',
    isDefault: 1,
  }).then((res) => {
    if (res && res.success) {
      let temp = proxy.$fn.getPrintTemp(res.data[0])
      getOfflinePrintData(temp, row)
    }
  })
}
function getOfflinePrintData(temp, row) {
  let params = {
    tableKey:
      'stockInventoryPrint-com.slip.spd.entity.vo.stock.InventoryOrderDetailVO',
    orderIds: [row.id],
  }
  getInventoryOrderOfflinePrint(params).then((res) => {
    if (res.success && res) {
      let data = proxy.$fn.deepClone(res.data)
      let newData = data.map((item) => {
        return {
          ...item,
          ...item.orderInfo,
        }
      })
      newData.forEach((val) => {
        if (val.details != null && val.details.length > 0) {
          val.details.forEach((value) => {
            if (value.sumAmount == 0) {
              value.sumAmount = null
            }
            if (value.qty == 0) {
              value.qty = null
            }
            if (value.stockQty == undefined || value.stockQty == null) {
              value.stockQty = 0
            }
          })
        }
      })
      proxy.$lodop.preview(
        temp,
        newData,
        !proxy.$permission('inventories:price')
      )
    }
  })
}
//打印盘点表总数
function printOfflineSimple(row) {
  fatchTemplateByCode({
    resourceCode: 'inventories:printOfflineSimple',
    isDefault: 1,
  }).then((res) => {
    if (res && res.success) {
      let temp = proxy.$fn.getPrintTemp(res.data[0])
      getOfflineSimplePrintData(temp, row)
    }
  })
}
function getOfflineSimplePrintData(temp, row) {
  let params = {
    orderIds: [row.id],
  }
  getInventoryOrderOfflineSimplePrint(params).then((res) => {
    if (res.success && res) {
      let data = proxy.$fn.deepClone(res.data)
      let newData = data.map((item) => {
        return {
          ...item,
          ...item.orderInfo,
        }
      })
      newData.forEach((val) => {
        if (val.details != null && val.details.length > 0) {
          val.details.forEach((value) => {
            if (value.sumAmount == undefined || value.sumAmount == null) {
              value.sumAmount = 0
            }
            if (value.stockQty == undefined || value.stockQty == null) {
              value.stockQty = 0
            }
          })
        }
      })
      proxy.$lodop.preview(
        temp,
        newData,
        !proxy.$permission('inventories:price')
      )
    }
  })
}
// 导出盘点表
function outputInventory(row) {
  let params = {
    tableKey:
      'stockInventoryPrint-com.slip.spd.entity.vo.stock.InventoryOrderDetailVO',
    orderIds: [row.id],
  }
  //盘点单导出
  inventoriesNotOnlineExcel(params).then((res) => {
    if (res) {
      proxy.$fn.parseExcel(res)
    }
  })
}
// 解锁
function unlock(row) {
  let data = [row.id]
  inventoriesUnLockStock(data).then((res) => {
    if (res) {
      getList()
    }
  })
}
// function showExportOrder(row) {
//   let params = {
//     id: row.inventoryExportOrderId,
//   }
//   proxy.$router.push({
//     name: 'inventoryAndExport',
//     params,
//   })
// }
// function showStoreOrder(row) {
//   let params = {
//     id: row.inventoryStoreOrderId,
//   }
//   proxy.$router.push({
//     name: 'inventoryAndStorage',
//     params,
//   })
// }
function showExportOrder(row) {
  // inventoryExportOrderId
  exportDetailInfo.value.visible = true
  exportDetailInfo.value.data = { id: row.inventoryExportOrderId }
}
function showStoreOrder(row) {
  // inventoryStoreOrderId
  storeDetailInfo.value.visible = true
  storeDetailInfo.value.data = { id: row.inventoryStoreOrderId }
}
function handleModify(data) {
  if (data) {
    inventoryProfitLossInfo.value.tableRow = { ...data }
    inventoryProfitLossInfo.value.visible = true
  }
}
function getCustomize(_slipSelectRequest = true) {
  let param = {
    tableKey:
      'stockInventoryOrderList-com.slip.spd.entity.vo.stock.InventoryOrderVO',
  }
  getCustomizeSetting(param).then((res) => {
    if (res && res.success) {
      let data = res.data
      filterInfo.value.query.customizeUserVO = data
      tableInfo.value.fieldList = proxy.$fn.setFieldList(
        tableInfo.value.fieldList,
        data.detail
      )
      let searchInfo = proxy.$fn.setSearchList(
        filterInfo.value.searchList,
        data.detail
      )
      filterInfo.value.query.queryMap = {
        ...searchInfo.queryMap,
        ...filterInfo.value.query.queryMap,
      }
      filterInfo.value.searchList = searchInfo.searchList
      filterInfo.value.searchList.forEach((item) => {
        item.event = search
      })
      filterInfo.value.copyQueryMap = proxy.$fn.deepClone(
        filterInfo.value.query.queryMap
      )
      slipSelectRequest.value = _slipSelectRequest
      tableInfo.value.api = getInventoriesCustomizeListPage
      getList()
    }
  })
}
function sortChange(column) {
  if (filterInfo.value.query.customizeUserVO.head.sortType === 0) {
    let arr = proxy.$fn.sortChange(column, filterInfo.value.sortArr)
    filterInfo.value.sortArr = arr
    filterInfo.value.query.sortString = arr.length ? arr.toString() : ''
    getList()
  }
}

onMounted(() => {
  initRules()
})
let obj = {
  statusValue: {
    label: '状态',
    value: 'statusValue',
    asValue: 'status',
    componentType: 'select-model',
    code: 'inventory_order_status',
    show: false,
    hidden: true,
  },
  orderNo: {
    label: '单号',
    value: 'orderNo',
    componentType: 'input',
    type: 'slot',
    show: false,
    hidden: true,
  },
  depotName: {
    label: '出库仓库',
    value: 'depotName',
    asValue: 'depotId',
    componentType: 'slip-select',
    query: {
      depotAuth: 'id',
      status: 1,
      useTypeId: '1',
      isCargoSpaceManage: 0,
    },
    api: getDepotAll,
    show: false,
    hidden: true,
  },
}
tableInfo.value.fieldList = Object.values({
  ...proxy.$fn.deepClone(proxy.$fieldfList.FieldList),
  ...proxy.$fn.deepClone(obj),
})
filterInfo.value.searchList = Object.values({
  ...proxy.$fn.deepClone(proxy.$fieldfList.FieldList),
  ...proxy.$fn.deepClone(obj),
})
getCustomize()
</script>

<style scoped></style>
